package com.xiaoqi.api.controller.portal;

import com.xiaoqi.api.query.ResourceQuery;
import com.xiaoqi.api.service.ResourceService;
import com.xiaoqi.api.utlis.PageResult;
import com.xiaoqi.api.utlis.Result;
import com.xiaoqi.api.vo.ResourceVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Slf4j
@RequestMapping("/portal/resource")
@Api(tags = "资源接口")
public class ResourceController {

    @Resource
    ResourceService resourceService;

    @ApiOperation("查询资源")
    @GetMapping
    public Result<List<ResourceVO>> find(ResourceQuery resourceQuery){ //resourceQuery封装了查询的条件
        PageResult<ResourceVO> page = resourceService.find(resourceQuery);

        return Result.ok("成功",page.getList(),page.getTotal());
    }

}
